package com.gitee.wsl.struct.grammar.parser.token


/**
 * A match of the [token] that starts at the [offset] position in the input
 * and is of specified [length].
 */
 open class TokenMatch(
    val token: Token,
    val offset: Int,
    val length: Int,
) {
    /**
     * Offset of the next character after the match.
     */
    val nextOffset: Int get() = offset + length
}


data class ComposeTokenMatch(
    val tokenMatchList: List<TokenMatch>
): TokenMatch(
    token = tokenMatchList.first().token,
    offset = tokenMatchList.first().offset,
    length = tokenMatchList.sumOf { it.length }
)